package com.fingerchar.admin.service;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fingerchar.core.base.service.impl.BaseService;
import com.fingerchar.db.domain.TtCalRecord;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author tangzf
 * @date 2022/9/10
 */
@Service
public class TtCalRecordService {

    @Resource
    private BaseService baseService;

    public Integer countByCreateTime(){

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-DD-dd");
        Date date = new Date();
        Date now = DateUtil.parse(DateUtil.format(new Date(), "yyyy-DD-dd"));
        Date yesterday = DateUtil.parse(DateUtil.format(DateUtils.addDays(new Date(), -1), "yyyy-DD-dd"));
        QueryWrapper<TtCalRecord> wrapper = new QueryWrapper<>();
        //大于等于昨天
        wrapper.ge("create_time", yesterday.getTime())
                //小于今天
                .lt("create_time", now.getTime());

        return baseService.counts(TtCalRecord.class, wrapper);

    }

}
